package com.leave.config;

import com.leave.interceptor.UserLoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * @ClassName WebConfig
 * @Description TODO
 * @Author lh
 * @Date 2021/7/1 18:58
 * @Version 1.0
 **/
@Configuration
public class WebConfig extends WebMvcConfigurationSupport {
    /**
     * 注册拦截器
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        super.addInterceptors(registry);
        //添加对用户是否登录的拦截器，并添加过滤项、排除项
        registry.addInterceptor(new UserLoginInterceptor()).addPathPatterns("/**")
                .excludePathPatterns("/static/css/**","/js/**","/img/**","/font/**","/images/**","/lay/**","/favicon.ico","/layui.all.js","/layui.js")//排除样式、脚本、图片等资源文件
                .excludePathPatterns("/")//排除登录页面
                .excludePathPatterns("/login")//排除登录操作
                .excludePathPatterns("/login/")//排除登录操作
                .excludePathPatterns("/data/login")//排除登录操作
                .excludePathPatterns("/registerPage")//排除注册页面
                .excludePathPatterns("/register")//排除注册操作
                .excludePathPatterns("/countdownPage");//排除倒计时页面
    }

}
